import {
  SAVE_BANNER,
  SAVE_HOTRECOMMENDS,
  SAVE_NEWALBUMS,
  SAVE_UPRANKING,
  SAVE_NEWRANKING,
  SAVE_ORIGINRANKING
} from './constant'
import {
  Map
} from 'immutable'

const defaultState = Map({
  banner: [],
  hotRecommends: [],
  newAlbums: [],
  upRanking: {},
  newRanking: {},
  originRanking: {},
})

function RecommendReducer(state = defaultState, action) {
  switch (action.type) {
    case SAVE_BANNER:
      return state.set('banner', action.banner)
    case SAVE_HOTRECOMMENDS:
      return state.set('hotRecommends', action.hotRecommends)
    case SAVE_NEWALBUMS:
      return state.set('newAlbums', action.newAlbums)
    case SAVE_UPRANKING:
      return state.set('upRanking', action.upRanking)
    case SAVE_NEWRANKING:
      return state.set('newRanking', action.newRanking)
    case SAVE_ORIGINRANKING:
      return state.set('originRanking', action.originRanking)
    default:
      return state;
  }
}

export default RecommendReducer